import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 编码生成规则信息 */
export interface CodeRule {
          ruleId: number; // 规则id
          ruleCode: string; // 规则编码
          ruleName: string; // 规则名称
          ruleLength: number; // 编码长度
          status: string; // 状态
          delFlag: string; // 删除标志（0代表存在 2代表删除）
          createDept: number; // 创建部门
          remark: string; // 备注
  }

// 编码生成规则 API
export const CodeRuleApi = {
  // 查询编码生成规则分页
  getCodeRulePage: async (params: any) => {
    return await request.get({ url: `/auto/code-rule/page`, params })
  },

  // 查询编码生成规则详情
  getCodeRule: async (id: number) => {
    return await request.get({ url: `/auto/code-rule/get?id=` + id })
  },

  // 新增编码生成规则
  createCodeRule: async (data: CodeRule) => {
    return await request.post({ url: `/auto/code-rule/create`, data })
  },

  // 修改编码生成规则
  updateCodeRule: async (data: CodeRule) => {
    return await request.put({ url: `/auto/code-rule/update`, data })
  },

  // 删除编码生成规则
  deleteCodeRule: async (id: number) => {
    return await request.delete({ url: `/auto/code-rule/delete?id=` + id })
  },

  /** 批量删除编码生成规则 */
  deleteCodeRuleList: async (ids: number[]) => {
    return await request.delete({ url: `/auto/code-rule/delete-list?ids=${ids.join(',')}` })
  },

  // 导出编码生成规则 Excel
  exportCodeRule: async (params) => {
    return await request.download({ url: `/auto/code-rule/export-excel`, params })
  },
}